package simpleGeom;

import java.util.List;
import java.util.Vector;

public class Bounds3D extends Box3D {

	public Bounds3D() {
		super();
		reset();
	}

	public void reset() {
		x1 = Float.POSITIVE_INFINITY;
		y1 = Float.POSITIVE_INFINITY;
		z1 = Float.POSITIVE_INFINITY;
		x2 = Float.NEGATIVE_INFINITY;
		y2 = Float.NEGATIVE_INFINITY;
		z2 = Float.NEGATIVE_INFINITY;
	}

	public void addPoint(HasPos3D p) {
		addPoint(p.getX(), p.getY(), p.getZ());
	}

	public void addPoint(float x, float y, float z) {
		if (x < x1)
			x1 = x;
		if (y < y1)
			y1 = y;
		if (z < z1)
			z1 = z;
		if (x > x2)
			x2 = x;
		if (y > y2)
			y2 = y;
		if (z > z2)
			z2 = z;
	}

	public void addAll(List<? extends HasPos3D> positions) {
		for (int i = 0; i < positions.size(); i++) {
			addPoint(positions.get(i));
		}
	}

	public void addAll(Vec3D[] points) {
		// TODO Auto-generated method stub
		for (int i = 0; i < points.length; i++) {
			addPoint(points[i]);
		}
	}

	public void translate(float tx, float ty, float tz) {
		x1 += tx;
		x2 += tx;
		y1 += ty;
		y2 += ty;
		z1 += tz;
		z2 += tz;
	}

}
